
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Command Handlers · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="infrastructure.html" />
    
    
    <link rel="prev" href="command-dispatchers.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../architecture-overview/">
            
                <a href="../../architecture-overview/">
            
                    
                    Architecture Overview
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../architecture-overview/ddd-cqrs-concepts.html">
            
                <a href="../../architecture-overview/ddd-cqrs-concepts.html">
            
                    
                    DDD & CQRS Concepts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../architecture-overview/event-sourcing.html">
            
                <a href="../../architecture-overview/event-sourcing.html">
            
                    
                    Event Sourcing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../architecture-overview/event-driven-microservices.html">
            
                <a href="../../architecture-overview/event-driven-microservices.html">
            
                    
                    Event-Driven Microservices
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../axon-server-introduction.html">
            
                <a href="../../axon-server-introduction.html">
            
                    
                    Axon Server
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../release-notes/">
            
                <a href="../../release-notes/">
            
                    
                    Release Notes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../release-notes/rn-axon-framework/">
            
                <a href="../../release-notes/rn-axon-framework/">
            
                    
                    Axon Framework
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1.1" data-path="../../release-notes/rn-axon-framework/rn-af-major-releases.html">
            
                <a href="../../release-notes/rn-axon-framework/rn-af-major-releases.html">
            
                    
                    Major Releases
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.1.2" data-path="../../release-notes/rn-axon-framework/rn-af-minor-releases.html">
            
                <a href="../../release-notes/rn-axon-framework/rn-af-minor-releases.html">
            
                    
                    Minor Releases
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../release-notes/rn-axon-server/">
            
                <a href="../../release-notes/rn-axon-server/">
            
                    
                    Axon Server
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="../../release-notes/rn-axon-server/rn-as-major-releases.html">
            
                <a href="../../release-notes/rn-axon-server/rn-as-major-releases.html">
            
                    
                    Major Releases
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="../../release-notes/rn-axon-server/rn-asse-minor-releases.html">
            
                <a href="../../release-notes/rn-axon-server/rn-asse-minor-releases.html">
            
                    
                    Minor Releases Standard Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="../../release-notes/rn-axon-server/rn-as-minor-releases.html">
            
                <a href="../../release-notes/rn-axon-server/rn-as-minor-releases.html">
            
                    
                    Minor Releases Enterprise Edition
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../release-notes/axon-framework-extensions.html">
            
                <a href="../../release-notes/axon-framework-extensions.html">
            
                    
                    Axon Framework Extensions
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Getting Started</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../getting-started/quick-start.html">
            
                <a href="../../getting-started/quick-start.html">
            
                    
                    Quick Start
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Axon Framework</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../introduction.html">
            
                <a href="../introduction.html">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../messaging-concepts/">
            
                <a href="../messaging-concepts/">
            
                    
                    Messaging Concepts
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../messaging-concepts/anatomy-message.html">
            
                <a href="../messaging-concepts/anatomy-message.html">
            
                    
                    Anatomy of a Message
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../messaging-concepts/message-correlation.html">
            
                <a href="../messaging-concepts/message-correlation.html">
            
                    
                    Message Correlation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../messaging-concepts/message-intercepting.html">
            
                <a href="../messaging-concepts/message-intercepting.html">
            
                    
                    Message Intercepting
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../messaging-concepts/supported-parameters-annotated-handlers.html">
            
                <a href="../messaging-concepts/supported-parameters-annotated-handlers.html">
            
                    
                    Supported Parameters for Annotated Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../messaging-concepts/exception-handling.html">
            
                <a href="../messaging-concepts/exception-handling.html">
            
                    
                    Exception Handling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../messaging-concepts/unit-of-work.html">
            
                <a href="../messaging-concepts/unit-of-work.html">
            
                    
                    Unit of Work
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="./">
            
                <a href="./">
            
                    
                    Commands
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="modeling/">
            
                <a href="modeling/">
            
                    
                    Modeling
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1.1" data-path="modeling/aggregate.html">
            
                <a href="modeling/aggregate.html">
            
                    
                    Aggregate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.2" data-path="modeling/multi-entity-aggregates.html">
            
                <a href="modeling/multi-entity-aggregates.html">
            
                    
                    Multi-Entity Aggregates
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.3" data-path="modeling/state-stored-aggregates.html">
            
                <a href="modeling/state-stored-aggregates.html">
            
                    
                    State Stored Aggregates
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.4" data-path="modeling/aggregate-creation-from-another-aggregate.html">
            
                <a href="modeling/aggregate-creation-from-another-aggregate.html">
            
                    
                    Aggregate Creation from another Aggregate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.5" data-path="modeling/aggregate-polymorphism.html">
            
                <a href="modeling/aggregate-polymorphism.html">
            
                    
                    Aggregate Polymorphism
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.6" data-path="modeling/conflict-resolution.html">
            
                <a href="modeling/conflict-resolution.html">
            
                    
                    Conflict Resolution
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="command-dispatchers.html">
            
                <a href="command-dispatchers.html">
            
                    
                    Command Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.3.3" data-path="command-handlers.html">
            
                <a href="command-handlers.html">
            
                    
                    Command Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="infrastructure.html">
            
                <a href="infrastructure.html">
            
                    
                    Infrastructure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="configuration.html">
            
                <a href="configuration.html">
            
                    
                    Configuration
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../events/">
            
                <a href="../events/">
            
                    
                    Events
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../events/event-dispatchers.html">
            
                <a href="../events/event-dispatchers.html">
            
                    
                    Event Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../events/event-handlers.html">
            
                <a href="../events/event-handlers.html">
            
                    
                    Event Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../events/event-processors/">
            
                <a href="../events/event-processors/">
            
                    
                    Event Processors
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.3.1" data-path="../events/event-processors/subscribing.html">
            
                <a href="../events/event-processors/subscribing.html">
            
                    
                    Subscribing Event Processors
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3.2" data-path="../events/event-processors/streaming.html">
            
                <a href="../events/event-processors/streaming.html">
            
                    
                    Streaming Event Processors
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../events/event-bus-and-event-store.html">
            
                <a href="../events/event-bus-and-event-store.html">
            
                    
                    Event Bus & Event Store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../events/event-versioning.html">
            
                <a href="../events/event-versioning.html">
            
                    
                    Event Versioning
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../events/event-serialization.html">
            
                <a href="../events/event-serialization.html">
            
                    
                    Event Serialization
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../queries/">
            
                <a href="../queries/">
            
                    
                    Queries
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../queries/query-processing.html">
            
                <a href="../queries/query-processing.html">
            
                    
                    Query Processing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../queries/query-dispatchers.html">
            
                <a href="../queries/query-dispatchers.html">
            
                    
                    Query Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../queries/query-handlers.html">
            
                <a href="../queries/query-handlers.html">
            
                    
                    Query Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../queries/implementations.html">
            
                <a href="../queries/implementations.html">
            
                    
                    Implementations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../queries/configuration.html">
            
                <a href="../queries/configuration.html">
            
                    
                    Configuration
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../sagas/">
            
                <a href="../sagas/">
            
                    
                    Sagas
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../sagas/implementation.html">
            
                <a href="../sagas/implementation.html">
            
                    
                    Implementation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../sagas/associations.html">
            
                <a href="../sagas/associations.html">
            
                    
                    Associations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../sagas/infrastructure.html">
            
                <a href="../sagas/infrastructure.html">
            
                    
                    Infrastructure
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../deadlines/">
            
                <a href="../deadlines/">
            
                    
                    Deadlines
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../deadlines/deadline-managers.html">
            
                <a href="../deadlines/deadline-managers.html">
            
                    
                    Deadline Managers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../deadlines/event-schedulers.html">
            
                <a href="../deadlines/event-schedulers.html">
            
                    
                    Event Schedulers
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../testing/">
            
                <a href="../testing/">
            
                    
                    Testing
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="../testing/commands-events.html">
            
                <a href="../testing/commands-events.html">
            
                    
                    Commands / Events
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="../testing/sagas-1.html">
            
                <a href="../testing/sagas-1.html">
            
                    
                    Sagas
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../tuning/">
            
                <a href="../tuning/">
            
                    
                    Tuning
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.9.1" data-path="../tuning/event-snapshots.html">
            
                <a href="../tuning/event-snapshots.html">
            
                    
                    Event Snapshots
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9.2" data-path="../tuning/event-processing.html">
            
                <a href="../tuning/event-processing.html">
            
                    
                    Event Processing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9.3" data-path="../tuning/command-processing.html">
            
                <a href="../tuning/command-processing.html">
            
                    
                    Command Processing
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="../monitoring-and-metrics.html">
            
                <a href="../monitoring-and-metrics.html">
            
                    
                    Monitoring and Metrics
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="../spring-boot-integration.html">
            
                <a href="../spring-boot-integration.html">
            
                    
                    Spring Boot Integration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="../modules.html">
            
                <a href="../modules.html">
            
                    
                    Modules
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Axon Server</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../axon-server/introduction.html">
            
                <a href="../../axon-server/introduction.html">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../../axon-server/installation/">
            
                <a href="../../axon-server/installation/">
            
                    
                    Installation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1" data-path="../../axon-server/installation/local-installation/">
            
                <a href="../../axon-server/installation/local-installation/">
            
                    
                    Local Installation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1.1" data-path="../../axon-server/installation/local-installation/axon-server-se.html">
            
                <a href="../../axon-server/installation/local-installation/axon-server-se.html">
            
                    
                    Axon Server SE
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.1.2" data-path="../../axon-server/installation/local-installation/axon-server-ee.html">
            
                <a href="../../axon-server/installation/local-installation/axon-server-ee.html">
            
                    
                    Axon Server EE
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2.2" data-path="../../axon-server/installation/docker-k8s/">
            
                <a href="../../axon-server/installation/docker-k8s/">
            
                    
                    Docker / K8s
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.2.1" data-path="../../axon-server/installation/docker-k8s/axon-server-se.html">
            
                <a href="../../axon-server/installation/docker-k8s/axon-server-se.html">
            
                    
                    Axon Server SE
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.2.2" data-path="../../axon-server/installation/docker-k8s/axon-server-ee.html">
            
                <a href="../../axon-server/installation/docker-k8s/axon-server-ee.html">
            
                    
                    Axon Server EE
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../../axon-server/administration/">
            
                <a href="../../axon-server/administration/">
            
                    
                    Administration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="../../axon-server/administration/admin-configuration/">
            
                <a href="../../axon-server/administration/admin-configuration/">
            
                    
                    Configuration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1.1" data-path="../../axon-server/administration/admin-configuration/configuration.html">
            
                <a href="../../axon-server/administration/admin-configuration/configuration.html">
            
                    
                    System Properties
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.1.2" data-path="../../axon-server/administration/admin-configuration/command-line-interface.html">
            
                <a href="../../axon-server/administration/admin-configuration/command-line-interface.html">
            
                    
                    Command Line Interface
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.1.3" data-path="../../axon-server/administration/admin-configuration/rest-api.html">
            
                <a href="../../axon-server/administration/admin-configuration/rest-api.html">
            
                    
                    REST API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="../../axon-server/administration/monitoring/">
            
                <a href="../../axon-server/administration/monitoring/">
            
                    
                    Monitoring
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.2.1" data-path="../../axon-server/administration/monitoring/actuator-endpoints.html">
            
                <a href="../../axon-server/administration/monitoring/actuator-endpoints.html">
            
                    
                    Actuator Endpoints
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.2.2" data-path="../../axon-server/administration/monitoring/grpc-metrics.html">
            
                <a href="../../axon-server/administration/monitoring/grpc-metrics.html">
            
                    
                    gRPC Metrics
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.2.3" data-path="../../axon-server/administration/monitoring/heartbeat-monitoring.html">
            
                <a href="../../axon-server/administration/monitoring/heartbeat-monitoring.html">
            
                    
                    Heartbeat Monitoring
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="../../axon-server/administration/clustering.html">
            
                <a href="../../axon-server/administration/clustering.html">
            
                    
                    Clusters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="../../axon-server/administration/replication-groups.html">
            
                <a href="../../axon-server/administration/replication-groups.html">
            
                    
                    Replication Groups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.5" data-path="../../axon-server/administration/multi-context.html">
            
                <a href="../../axon-server/administration/multi-context.html">
            
                    
                    Multi-Context
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.6" data-path="../../axon-server/administration/tagging.html">
            
                <a href="../../axon-server/administration/tagging.html">
            
                    
                    Tagging
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.7" data-path="../../axon-server/administration/backup-and-messaging-only-nodes.html">
            
                <a href="../../axon-server/administration/backup-and-messaging-only-nodes.html">
            
                    
                    Backup and Messaging-only Nodes
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.8" data-path="../../axon-server/administration/backups.html">
            
                <a href="../../axon-server/administration/backups.html">
            
                    
                    Backups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.9" data-path="../../axon-server/administration/recovery.html">
            
                <a href="../../axon-server/administration/recovery.html">
            
                    
                    Recovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.10" data-path="../../axon-server/administration/plugins.html">
            
                <a href="../../axon-server/administration/plugins.html">
            
                    
                    Plugins
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.11" data-path="../../axon-server/administration/error-codes.html">
            
                <a href="../../axon-server/administration/error-codes.html">
            
                    
                    Error Codes
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../axon-server/security/">
            
                <a href="../../axon-server/security/">
            
                    
                    Security
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="../../axon-server/security/ssl.html">
            
                <a href="../../axon-server/security/ssl.html">
            
                    
                    SSL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="../../axon-server/security/access-control.html">
            
                <a href="../../axon-server/security/access-control.html">
            
                    
                    Access Control
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="../../axon-server/security/access-control-se.html">
            
                <a href="../../axon-server/security/access-control-se.html">
            
                    
                    Access Control - Standard Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="../../axon-server/security/access-control-ee.html">
            
                <a href="../../axon-server/security/access-control-ee.html">
            
                    
                    Access Control - Enterprise Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.5" data-path="../../axon-server/security/access-control-clients.html">
            
                <a href="../../axon-server/security/access-control-clients.html">
            
                    
                    Access Control - Client Applications
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.6" data-path="../../axon-server/security/access-control-cli.html">
            
                <a href="../../axon-server/security/access-control-cli.html">
            
                    
                    Access Control - CLI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.7" data-path="../../axon-server/security/access-control-api.html">
            
                <a href="../../axon-server/security/access-control-api.html">
            
                    
                    Access Control - API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.8" data-path="../../axon-server/security/access-control-ldap.html">
            
                <a href="../../axon-server/security/access-control-ldap.html">
            
                    
                    Access Control - LDAP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.9" data-path="../../axon-server/security/access-control-oauth2.html">
            
                <a href="../../axon-server/security/access-control-oauth2.html">
            
                    
                    Access Control - OAuth 2.0
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../axon-server/performance/">
            
                <a href="../../axon-server/performance/">
            
                    
                    Performance
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.1" data-path="../../axon-server/performance/tuning-event-processing.html">
            
                <a href="../../axon-server/performance/tuning-event-processing.html">
            
                    
                    Event Segments
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5.2" data-path="../../axon-server/performance/flow-control.html">
            
                <a href="../../axon-server/performance/flow-control.html">
            
                    
                    Flow Control
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../../axon-server/migration/">
            
                <a href="../../axon-server/migration/">
            
                    
                    Migration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.6.1" data-path="../../axon-server/migration/standard-to-enterprise-edition.html">
            
                <a href="../../axon-server/migration/standard-to-enterprise-edition.html">
            
                    
                    Standard to Enterprise Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6.2" data-path="../../axon-server/migration/non-axon-server-to-axon-server.html">
            
                <a href="../../axon-server/migration/non-axon-server-to-axon-server.html">
            
                    
                    Non-Axon Server to Axon Server
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Extensions</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../extensions/spring-amqp.html">
            
                <a href="../../extensions/spring-amqp.html">
            
                    
                    Spring AMQP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../extensions/jgroups.html">
            
                <a href="../../extensions/jgroups.html">
            
                    
                    JGroups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../extensions/kafka.html">
            
                <a href="../../extensions/kafka.html">
            
                    
                    Kafka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../../extensions/kotlin.html">
            
                <a href="../../extensions/kotlin.html">
            
                    
                    Kotlin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../../extensions/mongo.html">
            
                <a href="../../extensions/mongo.html">
            
                    
                    Mongo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../../extensions/reactor/reactor.html">
            
                <a href="../../extensions/reactor/reactor.html">
            
                    
                    Reactor
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.6.1" data-path="../../extensions/reactor/reactive-gateways/reactive-gateways.html">
            
                <a href="../../extensions/reactor/reactive-gateways/reactive-gateways.html">
            
                    
                    Reactor Gateways
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../../extensions/spring-cloud.html">
            
                <a href="../../extensions/spring-cloud.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../../extensions/tracing.html">
            
                <a href="../../extensions/tracing.html">
            
                    
                    Tracing
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Appendices</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../../appendices/rdbms-tuning.html">
            
                <a href="../../appendices/rdbms-tuning.html">
            
                    
                    A. RDBMS Tuning
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../../appendices/message-handler-tuning/">
            
                <a href="../../appendices/message-handler-tuning/">
            
                    
                    B. Message Handler Tuning
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.2.1" data-path="../../appendices/message-handler-tuning/parameter-resolvers.html">
            
                <a href="../../appendices/message-handler-tuning/parameter-resolvers.html">
            
                    
                    Parameter Resolvers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2.2" data-path="../../appendices/message-handler-tuning/handler-enhancers.html">
            
                <a href="../../appendices/message-handler-tuning/handler-enhancers.html">
            
                    
                    Handler Enhancers
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../../appendices/meta-annotations.html">
            
                <a href="../../appendices/meta-annotations.html">
            
                    
                    C. Meta Annotations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../../appendices/identifier-generation.html">
            
                <a href="../../appendices/identifier-generation.html">
            
                    
                    D. Identifier Generation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../../appendices/query-reference.html">
            
                <a href="../../appendices/query-reference.html">
            
                    
                    E. Axon Server Query Language
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Command Handlers</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="command-handlers">Command Handlers</h1>
<h2 id="aggregate-command-handlers">Aggregate Command Handlers</h2>
<p>Although Command Handlers can be placed in regular components, it is recommended to define the Command Handlers directly on the Aggregate that contains the state to process this command.</p>
<p>To define a Command Handler in an Aggregate, simply annotate the method which should handle the command with <code>@CommandHandler</code>. The <code>@CommandHandler</code> annotated method will become a Command Handler for Command Messages where the <em>command name</em> matches fully qualified class name of the first parameter of that method. Thus, a method signature of <code>void handle(RedeemCardCommand cmd)</code> annotated with <code>@CommandHandler</code>, will be the Command Handler of the <code>RedeemCardCommand</code> Command Messages.</p>
<p>Command Messages can also be <a href="command-dispatchers.html">dispatched</a> with different <em>command names</em>. To be able to handle those correctly, the <code>String commandName</code> value can be specified in the <code>@CommandHandler</code> annotation.</p>
<p>In order for Axon to know which instance of an Aggregate type should handle the Command Message, the property carrying the Aggregate Identifier in the command object <strong>must</strong> be annotated with <code>@TargetAggregateIdentifier</code>. The annotation may be placed on either the field or an accessor method (e.g. a getter) in the Command object.</p>
<blockquote>
<p><strong>Routing in a distributed environment</strong></p>
<p>Regardless of the type of command, as soon as you start distributing your application (through Axon Server, for example), it is recommended to specify a routing key on the command. 
This is the job of the <code>@TargetAggregateIdentifier</code>, but in absence of a field worthy of the annotation, the <code>@RoutingKey</code> annotation should be added to ensure the command can be routed.</p>
<p>If neither annotation works for your use case, a different <code>RoutingStrategy</code> can be configured, as is explained in the <a href="infrastructure.html#routing-strategy">Routing Strategy</a> section.</p>
</blockquote>
<p>Taking the <code>GiftCard</code> Aggregate as an example, we can identify two Command Handlers on the Aggregate:</p>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> org.axonframework.commandhandling.CommandHandler;
<span class="hljs-keyword">import</span> org.axonframework.modelling.command.AggregateIdentifier;

<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.axonframework.modelling.command.AggregateLifecycle.apply;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">GiftCard</span> </span>{

    <span class="hljs-meta">@AggregateIdentifier</span>
    <span class="hljs-keyword">private</span> String id;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> remainingValue;

    <span class="hljs-meta">@CommandHandler</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">GiftCard</span><span class="hljs-params">(IssueCardCommand cmd)</span> </span>{
        apply(<span class="hljs-keyword">new</span> CardIssuedEvent(cmd.getCardId(), cmd.getAmount()));
    }

    <span class="hljs-meta">@CommandHandler</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handle</span><span class="hljs-params">(RedeemCardCommand cmd)</span> </span>{
        <span class="hljs-keyword">if</span> (cmd.getAmount() &lt;= <span class="hljs-number">0</span>) {
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> IllegalArgumentException(<span class="hljs-string">&quot;amount &lt;= 0&quot;</span>);
        }
        <span class="hljs-keyword">if</span> (cmd.getAmount() &gt; remainingValue) {
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> IllegalStateException(<span class="hljs-string">&quot;amount &gt; remaining value&quot;</span>);
        }
        apply(<span class="hljs-keyword">new</span> CardRedeemedEvent(id, cmd.getTransactionId(), cmd.getAmount()));
    }
    <span class="hljs-comment">// omitted event sourcing handlers</span>
}
</code></pre>
<p>The Command objects, <code>IssueCardCommand</code> and <code>RedeemCardCommand</code>, which <code>GiftCard</code> handles have the following format:</p>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> org.axonframework.modelling.command.TargetAggregateIdentifier;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">IssueCardCommand</span> </span>{

    <span class="hljs-meta">@TargetAggregateIdentifier</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String cardId;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> Integer amount;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">IssueCardCommand</span><span class="hljs-params">(String cardId, Integer amount)</span> </span>{
        <span class="hljs-keyword">this</span>.cardId = cardId;
        <span class="hljs-keyword">this</span>.amount = amount;
    }
    <span class="hljs-comment">// omitted getters, equals/hashCode, toString functions</span>
}

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RedeemCardCommand</span> </span>{

    <span class="hljs-meta">@TargetAggregateIdentifier</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String cardId;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String transactionId;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> Integer amount;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">RedeemCardCommand</span><span class="hljs-params">(String cardId, String transactionId, Integer amount)</span> </span>{
        <span class="hljs-keyword">this</span>.cardId = cardId;
        <span class="hljs-keyword">this</span>.transactionId = transactionId;
        <span class="hljs-keyword">this</span>.amount = amount;
    }
    <span class="hljs-comment">// omitted getters, equals/hashCode, toString functions</span>
}
</code></pre>
<p>The <code>cardId</code> present in both commands is the reference to a <code>GiftCard</code> instance and thus is annotated with the <code>@TargetAggregateIdentifier</code> annotation. Commands that create an Aggregate instance do not need to identify the target aggregate identifier, as there is no Aggregate in existence yet. It is nonetheless recommended for consistency to annotate the Aggregate Identifier on them as well.</p>
<p>If you prefer to use another mechanism for routing commands, the behavior can be overridden by supplying a custom <code>CommandTargetResolver</code>. This class should return the Aggregate Identifier and expected version (if any) based on a given command.</p>
<blockquote>
<p><strong>Aggregate Creation Command Handlers</strong></p>
<p>When the <code>@CommandHandler</code> annotation is placed on an aggregate&apos;s constructor, the respective command will create a new instance of that aggregate and add it to the repository. 
Those commands do not require to target a specific aggregate instance. 
Therefore, those commands need neither the <code>@TargetAggregateIdentifier</code> nor the <code>@TargetAggregateVersion</code> annotation.
Furthermore, a custom <code>CommandTargetResolver</code> will not be invoked for these commands.</p>
</blockquote>
<h3 id="business-logic-and-state-changes">Business Logic and State Changes</h3>
<p>Within an Aggregate there is a specific location to perform business logic validation and Aggregate state changes. The Command Handlers should <em>decide</em> whether the Aggregate is in the correct state. If yes, an Event is published. If not, the Command might be ignored or an exception could be thrown, depending on the needs of the domain.</p>
<p>State changes should <strong>not</strong> occur in <em>any</em> Command Handling function. The Event Sourcing Handlers should be the only methods where the Aggregate&apos;s state is updated. Failing to do so means the Aggregate would miss state changes when it is being sourced from it&apos;s events.</p>
<p>The<a href="../testing/commands-events.html"> Aggregate Test Fixture</a> will guard from unintentional state changes in Command Handling functions. It is thus advised to provide thorough test cases for <em>any</em> Aggregate implementation.</p>
<blockquote>
<p><strong>When to handle an Event</strong></p>
<p>The only state an Aggregate requires is the state it needs to make a decision. Handling an Event published by the Aggregate is thus only required if the state change the Event resembles is needed to drive future validation.</p>
</blockquote>
<h3 id="applying-events-from-event-sourcing-handlers">Applying Events from Event Sourcing Handlers</h3>
<p>In some cases, especially when the Aggregate structure grows beyond just a couple of Entities, it is cleaner to react on events being published in other Entities of the same Aggregate (multi Entity Aggregates are explained in more detail <a href="modeling/multi-entity-aggregates.html">here</a>). However, since the Event Handling methods are also invoked when reconstructing Aggregate state, special precautions must be taken.</p>
<p>It is possible to <code>apply()</code> new events inside an Event Sourcing Handler method. This makes it possible for an Entity &apos;B&apos; to apply an event in reaction to Entity &apos;A&apos; doing something. Axon will ignore the <code>apply()</code>invocation when replaying historic events upon sourcing the given Aggregate. Do note that in the scenario where Event Messages are published from an Event Sourcing Handler, the Event of the inner <code>apply()</code> invocation is only published to the entities after all entities have received the first event. If more events need to be published, based on the state of an entity after applying an inner event, use <code>apply(...).andThenApply(...)</code>.</p>
<blockquote>
<p><strong>Reacting to other Events</strong></p>
<p>An Aggregate <strong>cannot</strong> handle events from other sources then itself. This is intentional as the Event Sourcing Handlers are used to recreate the state of the Aggregate. For this it only needs it&apos;s own events as those represent it&apos;s state changes.</p>
<p>To make an Aggregate react on events from other Aggregate instances, <a href="../sagas">Sagas</a> or <a href="../events/event-handlers.html">Event Handling Components</a> should be leveraged</p>
</blockquote>
<h3 id="aggregate-command-handler-creation-policy">Aggregate Command Handler Creation Policy</h3>
<p>Up until now, we have depicted the <code>GiftCard</code> aggregate with roughly two types of command handlers:</p>
<ol>
<li><code>@CommandHandler</code> annotated constructors</li>
<li><code>@CommandHandler</code> annotated methods</li>
</ol>
<p>Option 1 will always expect to be the instantiation of the <code>GiftCard</code> aggregate, whilst option 2 expects to be targeted towards an existing aggregate instance. Although this may be the default, there is the option to define a <em>creation policy</em> on a command handler. This can be achieved by adding the <code>@CreationPolicy</code> annotation to a command handler annotated method, like so:</p>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> org.axonframework.commandhandling.CommandHandler;
<span class="hljs-keyword">import</span> org.axonframework.modelling.command.CreationPolicy;
<span class="hljs-keyword">import</span> org.axonframework.modelling.command.AggregateCreationPolicy;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">GiftCard</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">GiftCard</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-comment">// Required no-op constructor</span>
    }

    <span class="hljs-meta">@CommandHandler</span>
    <span class="hljs-meta">@CreationPolicy</span>(AggregateCreationPolicy.ALWAYS)
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handle</span><span class="hljs-params">(IssueCardCommand cmd)</span> </span>{
        <span class="hljs-comment">// An `IssueCardCommand`-handler which will create a `GiftCard` aggregate </span>
    }

    <span class="hljs-meta">@CommandHandler</span>
    <span class="hljs-meta">@CreationPolicy</span>(AggregateCreationPolicy.CREATE_IF_MISSING)
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handle</span><span class="hljs-params">(CreateOrRechargeCardCommand cmd)</span> </span>{
        <span class="hljs-comment">// A &apos;CreateOrRechargeCardCommand&apos;-handler which creates a `GiftCard` aggregate if it did not exist</span>
        <span class="hljs-comment">// Otherwise, it will update an existing `GiftCard` aggregate.</span>
    }
    <span class="hljs-comment">// omitted aggregate state, command handling logic and event sourcing handlers</span>
}
</code></pre>
<p>As is shown above, the <code>@CreationPolicy</code> annotation requires stating the <code>AggregateCreationPolicy</code>. This enumeration has the following options available:</p>
<ul>
<li><p><code>ALWAYS</code> - A creation policy of &quot;always&quot; will expect to instantiate the aggregate.
This effectively works like a command handler annotated constructor.
Without defining a return type, the aggregate identifier used during the creation will be returned.
Through this approach, it is possible to return other results next to the aggregate identifier.</p>
</li>
<li><p><code>CREATE_IF_MISSING</code> - A creation policy of &quot;create if missing&quot; can either create an aggregate or act on an existing instance.</p>
<p>This policy should be regarded as a create or update approach of an aggregate.</p>
</li>
<li><p><code>NEVER</code> - A creation policy of &quot;never&quot; will be handled on an existing aggregate instance.</p>
<p>This effectively works like any regular command handler annotated method.</p>
</li>
</ul>
<h2 id="external-command-handlers">External Command Handlers</h2>
<p>Command handling functions are most often directly placed on the Aggregate (as described in more detail <a href="command-handlers.html#aggregate-command-handlers">here</a>). There are situations however where it is not possible nor desired to route a command directly to an Aggregate instance. Message handling functions, like Command Handlers, can however be placed on any object. It is thus possible to instantiate a &apos;Command Handling Object&apos;.</p>
<p>A Command Handling Object is a simple (regular) object, which has <code>@CommandHandler</code> annotated methods. Unlike with Aggregates, there is only a <em>single</em> instance of a Command Handling Object, which handles <strong>all</strong> commands of the types it declares in its methods:</p>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> org.axonframework.commandhandling.CommandHandler;
<span class="hljs-keyword">import</span> org.axonframework.modelling.command.Repository;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">GiftCardCommandHandler</span> </span>{

    <span class="hljs-comment">// 1.</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> Repository&lt;GiftCard&gt; giftCardRepository;

    <span class="hljs-meta">@CommandHandler</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handle</span><span class="hljs-params">(RedeemCardCommand cmd)</span> </span>{
        giftCardRepository.load(cmd.getCardId()) <span class="hljs-comment">// 2.</span>
                          .execute(giftCard -&gt; giftCard.handle(cmd)); <span class="hljs-comment">// 3.</span>
    }

    <span class="hljs-comment">// omitted constructor</span>
}
</code></pre>
<p>In the above snippet we have decided that the <code>RedeemCardCommand</code> should no longer be directly handled on the <code>GiftCard</code>. Instead, we load the <code>GiftCard</code> manually and execute the desired method on it:</p>
<ol>
<li><p>The <code>Repository</code> for the <code>GiftCard</code> Aggregate, used for retrieval and storage of an Aggregate.</p>
<p>If <code>@CommandHandler</code> methods are placed directly on the Aggregate, Axon will automatically know to call the <code>Repository</code> to load a given instance.</p>
<p>It is thus <em>not</em> mandatory to directly access the <code>Repository</code>, but a <a href="../../architecture-overview#separation-of-business-logic-and-infrastructure">design choice</a>.</p>
</li>
<li><p>To load the intended <code>GiftCard</code> Aggregate instance, the <code>Repository#load(String)</code> method is used.</p>
<p>The provided parameter should be the Aggregate identifier.</p>
</li>
<li><p>After that Aggregate has been loaded, the <code>Aggregate#execute(Consumer)</code> function should be invoked to perform an operation on the Aggregate.</p>
<p>Using the <code>execute</code> function ensure that the Aggregate life cycle is correctly started.</p>
</li>
</ol>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="command-dispatchers.html" class="navigation navigation-prev " aria-label="Previous page: Command Dispatchers">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="infrastructure.html" class="navigation navigation-next " aria-label="Next page: Infrastructure">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Command Handlers","level":"3.3.3","depth":2,"next":{"title":"Infrastructure","level":"3.3.4","depth":2,"path":"axon-framework/axon-framework-commands/infrastructure.md","ref":"axon-framework/axon-framework-commands/infrastructure.md","articles":[]},"previous":{"title":"Command Dispatchers","level":"3.3.2","depth":2,"path":"axon-framework/axon-framework-commands/command-dispatchers.md","ref":"axon-framework/axon-framework-commands/command-dispatchers.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"axon-framework/axon-framework-commands/command-handlers.md","mtime":"2021-09-07T13:08:08.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-13T08:33:36.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

